home *** CD-ROM | disk | FTP | other *** search
- Path: abcfd20.larc.nasa.gov!amiga-request
- From: amiga-request@abcfd20.larc.nasa.gov (Amiga Sources/Binaries Moderator)
- Subject: v90i226: crabs - crustaceans consume your console, Part01/01
- Reply-To: thyssen@batserver.cs.uq.oz.au (Anthony Thyssen)
- Newsgroups: comp.sources.amiga
- Message-ID: <comp.sources.amiga:v90i226@abcfd20.larc.nasa.gov>
- Date: 17 Aug 90 18:39:31 GMT
- Approved: tadguy@uunet.UU.NET (Tad Guy)
- X-Mail-Submissions-To: amiga@uunet.uu.net
- X-Post-Discussions-To: comp.sys.amiga
-
- Submitted-by: thyssen@batserver.cs.uq.oz.au (Anthony Thyssen)
- Posting-number: Volume 90, Issue 226
- Archive-name: examples/crabs/part01
-
- [ uuencoded executable, bitmaps, and icons included ...tad ]
-
- This program is a hack I wanted to do for the amiga after seeing
- an article about crabs in Scientific American. The program is my own
- and is different to the original idea in that the crabs reproduce.
- The source is included and is a good example of hacking the main
- workbench screen directly
-
- #!/bin/sh
- # This is a shell archive. Remove anything before this line, then unpack
- # it by saving it into a file and typing "sh file". To overwrite existing
- # files, type "sh file -c". You can also feed this as standard input via
- # unshar, or by typing "sh <file", e.g.. If this archive is complete, you
- # will see the following message at the end:
- # "End of archive 1 (of 1)."
- # Contents: .info.uu blob blobmask crab16.uu crab8 crabmask16.uu
- # crabmask8 crabs.c crabs.h crabs.info.uu crabs.uu intergerize.c
- # makefile merge.c rotate.c
- # Wrapped by tadguy@abcfd20 on Fri Aug 17 14:39:29 1990
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f '.info.uu' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'.info.uu'\"
- else
- echo shar: Extracting \"'.info.uu'\" \(66 characters\)
- sed "s/^X//" >'.info.uu' <<'END_OF_FILE'
- Xbegin 644 .info
- X6\TP`$@``$2D```+-```*X&-R86)S"@``9
- X``
- Xend
- Xsize 22
- END_OF_FILE
- if test 66 -ne `wc -c <'.info.uu'`; then
- echo shar: \"'.info.uu'\" unpacked with wrong size!
- fi
- # end of '.info.uu'
- fi
- if test -f 'blob' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'blob'\"
- else
- echo shar: Extracting \"'blob'\" \(78 characters\)
- sed "s/^X//" >'blob' <<'END_OF_FILE'
- X............
- X....****....
- X..********..
- X..********..
- X....****....
- X............
- END_OF_FILE
- if test 78 -ne `wc -c <'blob'`; then
- echo shar: \"'blob'\" unpacked with wrong size!
- fi
- # end of 'blob'
- fi
- if test -f 'blobmask' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'blobmask'\"
- else
- echo shar: Extracting \"'blobmask'\" \(78 characters\)
- sed "s/^X//" >'blobmask' <<'END_OF_FILE'
- X...******...
- X.**********.
- X************
- X************
- X.**********.
- X...******...
- END_OF_FILE
- if test 78 -ne `wc -c <'blobmask'`; then
- echo shar: \"'blobmask'\" unpacked with wrong size!
- fi
- # end of 'blobmask'
- fi
- if test -f 'crab16.uu' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'crab16.uu'\"
- else
- echo shar: Extracting \"'crab16.uu'\" \(572 characters\)
- sed "s/^X//" >'crab16.uu' <<'END_OF_FILE'
- Xbegin 644 crab16
- XM+BXN+BXN+BXN+BXN+BXN+@HN+BXN+BXN+BXN+BXN+BXN"BXN+BXJ*BXN+BXJ"
- XM*BXN+BX*+BXN*BHJ+BXN+BHJ*BXN+@HN+BXJ*BXN+BXN+BHJ+BXN"BXN*BXNZ
- XM+BHN+BHN+BXJ+BX*+BXJ+BXN*BHJ*BXN+BHN+@HN+BXJ*BHJ*BHJ*BHJ+BXN"
- XM"BXN+BXN*BHJ*BHJ+BXN+BX*+BXJ*BHJ*BHJ*BHJ*BHN+@HN*BXN+BHJ*BHJ*
- XM*BXN+BHN"BXN+BXJ+BHJ*BHN*BXN+BX*+BXN*BXN+BXN+BXN*BXN+@HN+BXJ^
- XM*BXN+BXN+BHJ+BXN"BXN+BXN+BXN+BXN+BXN+BX*+BXN+BXN+BXN+BXN+BXN"
- XM+@H:&AH:&AH:&AH:&AH:&AH:&AH:&AH:&AH:&AH:&AH:&AH:&AH:&AH:&AH:6
- XM&AH:&AH:&AH:&AH:&AH:&AH:&AH:&AH:&AH:&AH:&AH:&AH:&AH:&AH:&AH:2
- X8&AH:&AH:&AH:&AH:&AH:&AH:&AH:&AH:P
- X``
- Xend
- Xsize 384
- END_OF_FILE
- if test 572 -ne `wc -c <'crab16.uu'`; then
- echo shar: \"'crab16.uu'\" unpacked with wrong size!
- fi
- # end of 'crab16.uu'
- fi
- if test -f 'crab8' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'crab8'\"
- else
- echo shar: Extracting \"'crab8'\" \(110 characters\)
- sed "s/^X//" >'crab8' <<'END_OF_FILE'
- X..........
- X..**.***..
- X.****.***.
- X.*......*.
- X.*.****.*.
- X..******..
- X..******..
- X.********.
- X..*....*..
- X..........
- END_OF_FILE
- if test 110 -ne `wc -c <'crab8'`; then
- echo shar: \"'crab8'\" unpacked with wrong size!
- fi
- # end of 'crab8'
- fi
- if test -f 'crabmask16.uu' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'crabmask16.uu'\"
- else
- echo shar: Extracting \"'crabmask16.uu'\" \(576 characters\)
- sed "s/^X//" >'crabmask16.uu' <<'END_OF_FILE'
- Xbegin 644 crabmask16
- XM+BXN+BXN+BXN+BXN+BXN+@HN+BXN*BHJ+BXJ*BHN+BXN"BXN*BHJ*BHJ*BHJ2
- XM*BHJ+BX*+BXJ*BHJ*BHJ*BHJ*BHN+@HN*BHJ*BHJ*BHJ*BHJ*BHN"BXJ*BHJF
- XM*BHJ*BHJ*BHJ*BX*+BHJ*BHJ*BHJ*BHJ*BHJ+@HN+BHJ*BHJ*BHJ*BHJ*BXN^
- XM"BXN*BHJ*BHJ*BHJ*BHJ+BX*+BHJ*BHJ*BHJ*BHJ*BHJ+@HN*BHJ*BHJ*BHJ>
- XM*BHJ*BHN"BXJ*BHJ*BHJ*BHJ*BHJ*BX*+BXJ*BHJ*BHJ*BHJ*BHN+@HN+BHJF
- XM*BHJ*BHJ*BHJ*BXN"BXN+BXJ*BHN+BHJ*BXN+BX*+BXN+BXN+BXN+BXN+BXN.
- XM+@H:&AH:&AH:&AH:&AH:&AH:&AH:&AH:&AH:&AH:&AH:&AH:&AH:&AH:&AH:6
- XM&AH:&AH:&AH:&AH:&AH:&AH:&AH:&AH:&AH:&AH:&AH:&AH:&AH:&AH:&AH:2
- X8&AH:&AH:&AH:&AH:&AH:&AH:&AH:&AH:P
- X``
- Xend
- Xsize 384
- END_OF_FILE
- if test 576 -ne `wc -c <'crabmask16.uu'`; then
- echo shar: \"'crabmask16.uu'\" unpacked with wrong size!
- fi
- # end of 'crabmask16.uu'
- fi
- if test -f 'crabmask8' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'crabmask8'\"
- else
- echo shar: Extracting \"'crabmask8'\" \(111 characters\)
- sed "s/^X//" >'crabmask8' <<'END_OF_FILE'
- X..******..
- X.********.
- X**********
- X**********
- X**********
- X**********
- X**********
- X**********
- X.********.
- X..******..
- X
- END_OF_FILE
- if test 111 -ne `wc -c <'crabmask8'`; then
- echo shar: \"'crabmask8'\" unpacked with wrong size!
- fi
- # end of 'crabmask8'
- fi
- if test -f 'crabs.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'crabs.c'\"
- else
- echo shar: Extracting \"'crabs.c'\" \(14330 characters\)
- sed "s/^X//" >'crabs.c' <<'END_OF_FILE'
- X/************************************************************************/
- X/* */
- X/* ###################### */
- X/* A n t h o n y ## ## ## */
- X/* ########## */
- X/* T h y s s e n #### ## #### */
- X/* #### ## #### */
- X/* #### ## #### */
- X/* */
- X/************************************************************************/
- X
- X/*
- X** Crabs - also for AMIGA under lattace C
- X*/
- X
- X#include <stdio.h>
- X#include <string.h>
- X#include <intuition/intuition.h>
- X#include <graphics/gfxmacros.h>
- X#include <exec/exec.h>
- X#include <proto/all.h>
- X#define BM_SRC 0xC0 /* minterm source only */
- X#define BM_DST 0xA0 /* minterm destination only */
- X
- X#include "crabs.h"
- X
- X /* intuition variables */
- Xstruct Library *IntuitionBase = NULL, *GfxBase = NULL;
- Xstruct Screen *WBScrn = NULL;
- Xstruct Window *Window = NULL; /* Window pointer */
- Xstruct RastPort *RPwindow = NULL; /* windows raster port */
- Xstruct Remember *Remember = NULL; /* memory allocation memory */
- Xstruct Task *MyTask = NULL; /* my tasks address */
- Xstruct IntuiMessage *message = NULL;
- Xint WBScrX, WBScrY; /* size of workbench screen */
- XULONG WindowSignal; /* IDCMP window signal */
- Xstruct NewWindow NW = {
- X 30, 200, 350, 40, 0, 1, /* position, size and colors */
- X CLOSEWINDOW, /* IDCMP messages */
- X ACTIVATE| SIMPLE_REFRESH| WINDOWDEPTH|
- X WINDOWDRAG| WINDOWCLOSE, /* window flags */
- X NULL, NULL, /* gadget, checkmark */
- X (UBYTE *) " << CRABS >> ", /* name of window */
- X NULL,NULL, /* screen-> , BitMap-> */
- X 0,0,0,0, /* min and max size (disable) */
- X WBENCHSCREEN /* screen type */
- X };
- X
- X
- X /* program varibles */
- Xtypedef struct {
- X int x, y;
- X} point;
- X
- Xtypedef enum {
- X Looking, /* crab is looking for food */
- X Nibbling, /* crab took a nibble and is stepping back */
- X Munching /* crab is eating the food (after step back) */
- X} crabstatus;
- X
- Xstatic struct {
- X crabstatus stat; /* current status of crab */
- X point pos; /* upper left corner screen coords */
- X point vel; /* velocity (pixels/cycle) */
- X point old; /* last position for backward step */
- X int lp; /* life points of this crab */
- X struct RastPort *RP; /* which map is the crab using */
- X} crab[MAXCRABS]; /* crabs' state */
- X
- Xint NumCrabs = 0; /* number of crabs on screen */
- X
- X/* Crab images to be drawen to the screen using the mask */
- Xunsigned short chip crabup[] = /* facing up */
- X# include "crabup.i"
- X#ifndef ONEIMAGE
- Xunsigned short chip crabdown[] = /* facing down */
- X# include "crabdown.i"
- Xunsigned short chip crabright[] = /* facing right */
- X# include "crabright.i"
- Xunsigned short chip crableft[] = /* facing left */
- X# include "crableft.i"
- X#endif
- Xunsigned short chip crabmask[] = /* crabs mask */
- X# include "crabmask.i"
- X
- X /* Bitmaps and raster ports of the screens */
- Xstruct BitMap BMtemp, BMmask, BMup;
- Xstruct RastPort RPtemp, RPmask, RPup, RPscreen;
- X#ifndef ONEIMAGE
- Xstruct BitMap BMdown, BMright, BMleft;
- Xstruct RastPort RPdown, RPright, RPleft;
- X#endif
- X
- X
- X /* function declarations */
- Xextern void Init(), OpenLibraries(), InitWindow(), InitRP(), Print();
- Xextern void CrabsExit(), Cycle(), DrawCrab(), HideCrab(), ModVel(), NewVel();
- Xextern BOOL MoveCrab(), TestCrab(), TestBackground();
- Xextern void RandInit();
- Xextern int RandInt();
- X
- X#ifdef CBACK
- X /* Cback.o initializations */
- XLONG _stack = 2000;
- Xchar *_procname = "Crabs";
- XLONG _priority = -1;
- XLONG _BackGroundIO = 0;
- X#endif
- X
- Xvoid
- X_main()
- X{
- X Init();
- X
- X for (;;) {
- X Cycle();
- X }
- X /* NOTREACHED */
- X}
- X
- Xvoid
- XInit()
- X/* set up initial crab layer */
- X{
- X int i; /* crab # */
- X
- X OpenLibraries(); /* open the various system structures */
- X
- X if( ! (Window = OpenWindow( &NW )) )
- X CrabsExit(NULL);
- X RPwindow = Window->RPort;
- X WindowSignal = 1<<Window->UserPort->mp_SigBit;
- X
- X InitWindow();
- X
- X MyTask = FindTask( NULL );
- X WBScrn = Window->WScreen;
- X WBScrX = WBScrn->Width -SIZE;
- X WBScrY = WBScrn->Height -SIZE/2;
- X
- X memcpy((char *) &RPscreen, (char *) &(WBScrn->RastPort),
- X sizeof( struct RastPort ));
- X
- X InitRP(&RPup, &BMup, &crabup);
- X InitRP(&RPmask, &BMmask, &crabmask);
- X InitRP(&RPtemp, &BMtemp, NULL);
- X#ifndef ONEIMAGE
- X InitRP(&RPdown, &BMdown, &crabdown);
- X InitRP(&RPleft, &BMdown, &crableft);
- X InitRP(&RPright, &BMright, &crabright);
- X#endif
- X
- X RandInit();
- X
- X /* Create initial set of crabs: */
- X for (NumCrabs = 0; NumCrabs < STARTCRABS; NumCrabs++) {
- X for (i = PLACELIM; i > 0; i--) {
- X crab[NumCrabs].pos.x = RandInt(0, WBScrX-1);
- X crab[NumCrabs].pos.y = RandInt(0, WBScrY-1);
- X crab[NumCrabs].old = crab[NumCrabs].pos;
- X if( !TestBackground(NumCrabs) )
- X break; /* space found */
- X }
- X if( !i ) /* did we reach the placement limit */
- X CrabsExit("Can't place crabs! No empty space found!");
- X crab[NumCrabs].lp = REPROlp / 2;
- X crab[NumCrabs].stat = Looking;
- X NewVel(NumCrabs);
- X DrawCrab(NumCrabs);
- X }
- X}
- X
- Xvoid
- XOpenLibraries()
- X{
- X if( ! (IntuitionBase = OpenLibrary( "intuition.library", 0 )) )
- X CrabsExit("Can't open Intuition Library");
- X if( ! (GfxBase = OpenLibrary( "graphics.library", 0 )) )
- X CrabsExit("Can't Open Graphics Library");
- X}
- X
- Xvoid
- XInitWindow()
- X{
- X Move(RPwindow, Window->BorderLeft,
- X Window->BorderTop + RPwindow->TxBaseline );
- X SetAPen(RPwindow, 3);
- X Print("Reproducing Crabs by Anthony Thyssen");
- X SetAPen(RPwindow, 1);
- X Print(" Original idea from Scientific American");
- X}
- X
- Xvoid
- XInitRP(rp, bm, image)
- X struct RastPort *rp;
- X struct BitMap *bm;
- X short *image;
- X{
- X InitBitMap(bm, 1, SIZE,SIZE/2);
- X if( image )
- X bm->Planes[0] = (PLANEPTR) image;
- X else
- X if( !(bm->Planes[0] = (PLANEPTR)
- X AllocRemember( &Remember, RASSIZE(SIZE,SIZE/2),
- X MEMF_CHIP | MEMF_CLEAR) ) ) { /* allocate with memory */
- X CrabsExit("Can't alloc raster");
- X }
- X InitRastPort( rp );
- X rp->BitMap = bm;
- X}
- X
- Xvoid
- XPrint(str)
- X char *str;
- X{
- X Text( RPwindow, str, strlen(str) );
- X Move( RPwindow, Window->BorderLeft,
- X RPwindow->cp_y + RPwindow->TxHeight); /* move to next line */
- X}
- X
- Xvoid
- XCrabsExit(exitmessage)
- X char *exitmessage;
- X/* exit crabs - remove all traces */
- X{
- X int i;
- X
- X for (i = 0; i < NumCrabs; ++i)
- X HideCrab(i);
- X
- X RefreshWindowFrame(Window);
- X InitWindow();
- X if( Window && exitmessage ) {
- X Print(exitmessage);
- X /*printf("%s\n", exitmessage); /* Debugging */
- X Delay(200);
- X }
- X
- X FreeRemember( &Remember, TRUE ); /* Frre all allocated memory */
- X
- X if( Window ) CloseWindow( Window );
- X if( GfxBase ) CloseLibrary( GfxBase );
- X if( IntuitionBase ) CloseLibrary( IntuitionBase );
- X
- X _exit(0);
- X}
- X
- Xvoid
- XCycle()
- X /* one motion cycle for all crabs */
- X{
- X int i;
- X
- X /* test for window closure */
- X if( message = (struct IntuiMessage *)GetMsg(Window->UserPort) ) {
- X ReplyMsg( (struct Message *)message );
- X switch( message->Class ) {
- X case CLOSEWINDOW : /* window closed message */
- X CrabsExit("Crabs are Exiting");
- X }
- X } /* Message test */
- X
- X if( NumCrabs < 5 )
- X Delay( DELAY ); /* slow down the small number of crabs */
- X
- X for (i = 0; i < NumCrabs; i++) {
- X
- X /* did something bite the crab - image corrupted ? */
- X if (TestCrab(i)) { /* if so damage the crab */
- X crab[i].lp -= BITElp;
- X NewVel(i);
- X }
- X
- X switch( crab[i].stat ) { /* do the nessary move */
- X case Looking:
- X HideCrab(i); /* erase crab from previous position */
- X crab[i].old = crab[i].pos; /* record current position */
- X if (MoveCrab(i)) /* find the new positioN */
- X crab[i].lp -= BOUNCElp; /* crab bounced - that smarts */
- X if (TestBackground(i)) /* Test if crab hits an object */
- X crab[i].stat = Nibbling; /* if so crab will now nibble */
- X crab[i].lp -= MOVElp; /* drain movement cost from crab */
- X if (crab[i].lp < 0) { /* check on starvation */
- X crab[i] = crab[--NumCrabs];
- X if (NumCrabs == 0)
- X CrabsExit("The last Crab just died!\n");
- X i--;
- X continue; /* repeat this crab as it is the next one */
- X }
- X DrawCrab(i); /* redraw crab here */
- X ModVel(i, 1); /* very slight direction change */
- X break;
- X
- X case Nibbling:
- X HideCrab(i); /* erase crab from previous position */
- X crab[i].pos = crab[i].old; /* move crab backwards */
- X DrawCrab(i); /* draw crab here */
- X crab[i].stat = Munching; /* chew over the food */
- X break;
- X
- X case Munching:
- X crab[i].lp += FEEDlp; /* feed the food to the crab */
- X ModVel(i, FEEDVEL); /* look in roughly the same dir as before */
- X crab[i].stat = Looking; /* time taken to eat - look for more */
- X if (crab[i].lp >= REPROlp) { /* check for reproduction */
- X HideCrab(i); /* remove parent */
- X crab[i].lp /= 2; /* half life force */
- X if (NumCrabs < MAXCRABS) { /* is a new crab is possible */
- X crab[NumCrabs] = crab[i]; /* child is a copy of parent */
- X crab[NumCrabs].vel.x = -crab[NumCrabs].vel.x; /* reverse dir */
- X crab[NumCrabs].vel.y = -crab[NumCrabs].vel.y;
- X crab[NumCrabs].lp -= BITElp; /* child is weak */
- X MoveCrab(i); /* move crabs away from each other */
- X MoveCrab(NumCrabs++); /* move child twice - inc number crabs */
- X /* leave the child undrawen and corrupted! */
- X }
- X DrawCrab(i); /* draw parent regardless of child state */
- X }
- X break;
- X }
- X } /* move next crab */
- X}
- X
- XBOOL
- XMoveCrab(i)
- X int i;
- X/* move crab to on screen position - don't draw it */
- X/* if the crab hits edge of screen return TRUE */
- X{
- X BOOL hit = FALSE;
- X
- X crab[i].pos.x += crab[i].vel.x; /* motion */
- X crab[i].pos.y += crab[i].vel.y;
- X if( crab[i].pos.x < 0 ) {
- X crab[i].pos.x = 0;
- X crab[i].vel.x = abs(crab[i].vel.x);
- X hit = TRUE;
- X }
- X if( crab[i].pos.x > WBScrX ) {
- X crab[i].pos.x = WBScrX;
- X crab[i].vel.x = -abs(crab[i].vel.x);
- X hit = TRUE;
- X }
- X if( crab[i].pos.y < 0 ) {
- X crab[i].pos.y = 0;
- X crab[i].vel.y = abs(crab[i].vel.y);
- X hit = TRUE;
- X }
- X if( crab[i].pos.y > WBScrY ) {
- X crab[i].pos.y = WBScrY;
- X crab[i].vel.y = -abs(crab[i].vel.y);
- X hit = TRUE;
- X }
- X return (hit);
- X}
- X
- XBOOL
- XTestCrab(i)
- X int i;
- X/* test the crabs image on the screen. return TRUE if corrupt */
- X/* invisible crabs are the background texture */
- X{
- X int j;
- X UBYTE *byte;
- X
- X /* get crab stored on screen */
- X ClipBlit( &RPscreen, crab[i].pos.x, crab[i].pos.y,
- X &RPtemp, 0, 0, SIZE, SIZE/2, BM_SRC );
- X /* mask out background */
- X ClipBlit( &RPmask, 0, 0, &RPtemp, 0, 0,
- X SIZE, SIZE/2, BM_SRC & BM_DST );
- X /* xor with crab image */
- X ClipBlit( crab[i].RP, 0, 0, &RPtemp, 0, 0,
- X SIZE, SIZE/2, BM_SRC ^ BM_DST );
- X
- X /* check the data */
- X byte = BMtemp.Planes[0];
- X for (j = RASSIZE(SIZE, SIZE/2)-1; j >= 0; j--)
- X if( *(byte++) )
- X return TRUE;
- X
- X return FALSE;
- X}
- X
- XBOOL
- XTestBackground(i)
- X int i;
- X/* return TRUE if crab position is not the background */
- X{
- X int j;
- X UBYTE *byte;
- X
- X /* get screen at crab location */
- X ClipBlit( &RPscreen, crab[i].pos.x, crab[i].pos.y,
- X &RPtemp, 0, 0, SIZE, SIZE/2, BM_SRC );
- X /* mask out background */
- X ClipBlit( &RPmask, 0, 0, &RPtemp, 0, 0,
- X SIZE, SIZE/2, BM_SRC & BM_DST );
- X
- X /* check the data */
- X byte = BMtemp.Planes[0];
- X for (j = RASSIZE(SIZE, SIZE/2)-1; j >= 0; j--)
- X if( *(byte++) )
- X return TRUE;
- X
- X return FALSE;
- X}
- X
- Xvoid
- XHideCrab(i)
- X/* over write current crab with screen texture */
- X{
- X ClipBlit( &RPmask, 0, 0, &RPscreen, crab[i].pos.x, crab[i].pos.y,
- X SIZE, SIZE/2, ~BM_SRC & BM_DST );
- X}
- X
- Xvoid
- XDrawCrab(i)
- X int i;
- X/* Draw the crabs on the screen if visible */
- X{
- X HideCrab(i);
- X crab[i].RP = PICKMAP( crab[i].vel );
- X ClipBlit( crab[i].RP, 0, 0, &RPscreen, crab[i].pos.x, crab[i].pos.y,
- X SIZE, SIZE/2, BM_SRC | BM_DST );
- X}
- X
- Xvoid
- XNewVel(i) /* assign new velocity to crab */
- X int i; /* crab # */
- X{
- X crab[i].vel.x = RandInt(-MAXVEL, MAXVEL);
- X crab[i].vel.y = RandInt(-MAXVEL/2, MAXVEL/2);
- X
- X /* Velocity (0,0) is okay since we repeatedly modify all velocities. */
- X}
- X
- Xvoid
- XModVel(i, dv) /* randomly modify crab velocity */
- X int i,dv; /* crab, delta velocity */
- X{
- X int min,max; /* range of new velocity */
- X
- X min=crab[i].vel.x-dv;
- X max=crab[i].vel.x+dv;
- X if ( max > MAXVEL)
- X max = MAXVEL;
- X if ( min < -MAXVEL)
- X min = -MAXVEL;
- X crab[i].vel.x = RandInt(min, max);
- X
- X min=crab[i].vel.y-dv;
- X max=crab[i].vel.y+dv;
- X if ( max > MAXVEL/2)
- X max = MAXVEL/2;
- X if ( min < -MAXVEL/2)
- X min = -MAXVEL/2;
- X crab[i].vel.y = RandInt(min, max);
- X}
- X
- Xvoid
- XRandInit()
- X{
- X srand((int)time(NULL));
- X}
- X
- Xint
- XRandInt(lo, hi) /* generate random integer in range */
- X int lo, hi; /* range lo..hi inclusive */
- X{
- X return lo + (int)( (unsigned)rand() % (hi - lo +1) );
- X}
- X
- X
- END_OF_FILE
- if test 14330 -ne `wc -c <'crabs.c'`; then
- echo shar: \"'crabs.c'\" unpacked with wrong size!
- fi
- # end of 'crabs.c'
- fi
- if test -f 'crabs.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'crabs.h'\"
- else
- echo shar: Extracting \"'crabs.h'\" \(1513 characters\)
- sed "s/^X//" >'crabs.h' <<'END_OF_FILE'
- X/* The Crabs header file */
- X
- X#define STARTCRABS 1 /* default start number of crabs */
- X#define MAXCRABS 40 /* max number of crabs */
- X#define SIZE 12 /* X size of the bitmaps,half for Y */
- X#define ONEIMAGE /* movement style */
- X
- X#define MAXVEL 8 /* abs. bound on velocity component */
- X#define FEEDVEL 2 /* velocity change after a feed */
- X#define DELAY 3 /* sleep time bettween cycles */
- X#define PLACELIM 50 /* times to try to find a blank spot */
- X
- X
- X#define FEEDlp 12 /* number of life points in one feed */
- X#define BITElp 30 /* damage from being eaten */
- X#define MOVElp 1 /* life points for a move */
- X#define BOUNCElp 0 /* hiting the screen edge hurts */
- X#define REPROlp 400 /* life points to reproduce at */
- X
- X/* movement style */
- X#ifdef SIDEWAYS
- X# define PICKMAP(v) ( abs((v).x) > abs((v).y * 2 ) ? \
- X ( (v).y > 0 ? &RPdown : &RPup ) : \
- X ( (v).x > 0 ? &RPright : &RPleft ) )
- X#endif
- X
- X#ifdef FORWARD
- X# define PICKMAP(v) ( abs((v).x) > abs((v).y * 2 ) ? \
- X ( (v).x > 0 ? &RPright : &RPleft ) : \
- X ( (v).y > 0 ? &RPdown : &RPup ) )
- X#endif
- X
- X#ifdef ONEIMAGE /* only the crabup.i image is used */
- X# define PICKMAP(v) ( &RPup )
- X#endif
- END_OF_FILE
- if test 1513 -ne `wc -c <'crabs.h'`; then
- echo shar: \"'crabs.h'\" unpacked with wrong size!
- fi
- # end of 'crabs.h'
- fi
- if test -f 'crabs.info.uu' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'crabs.info.uu'\"
- else
- echo shar: Extracting \"'crabs.info.uu'\" \(387 characters\)
- sed "s/^X//" >'crabs.info.uu' <<'END_OF_FILE'
- Xbegin 644 crabs.info
- XMXQ```0```````````"(`#``$``,``0#`J#``````````````````````````"
- XM`````\(`P&Z(`,"H2(````"````````````````````````````B``L``@##=
- XM-;@#``````````__P```0`(/P``"```!P```$`#PP``$``/\P```("#PP```%
- XM@0``P```"``/P``"``?_P`````?_P``(``?_P```````````````````````T
- XM`````````````````````````````````````````````````````````````
- X8```````````!``````P````!``````$`/
- X``
- Xend
- Xsize 249
- END_OF_FILE
- if test 387 -ne `wc -c <'crabs.info.uu'`; then
- echo shar: \"'crabs.info.uu'\" unpacked with wrong size!
- fi
- # end of 'crabs.info.uu'
- fi
- if test -f 'crabs.uu' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'crabs.uu'\"
- else
- echo shar: Extracting \"'crabs.uu'\" \(7341 characters\)
- sed "s/^X//" >'crabs.uu' <<'END_OF_FILE'
- Xbegin 644 crabs
- XM```#\P`````````$``````````,```2(0```!@````````+"```#Z0``!(@DO
- XM2"0`2?D`````1_D```&<<@`@/````EM@`B;!4<C__"QX``0I3@'4*4\!W$*L*
- XM`=@F;@$4<``B/```,`!.KO[.*6L`F`'02JL`K&<``'`@#Y"O``0&@````(`I>
- XM0`&@80`!+B!K`*S1R-'((F@`$-/)T\D@`G(`$ADI20'DT(%2@$)G4H`"0/_^?
- XMG\!5@$)W"``@`E.`U($?L@``(`!3@E'(__8?O``@(`!3@A^Q(``@`%'*__@B'
- XM3R\)8```>"EK`#H!H'!_4H#1K`&@80``PD'K`%Q.KOZ`0>L`7$ZN_HPI0`'8B
- XM+P`D0"`J`"1G$BQL"O@@0"(H```I00'03J[_@B(J`"!G&B0\```#[4ZN_^(IY
- XM0`'@9PKEB"!`)V@`"`"D(&P!V"\(2&P!G"!H`"0I:``$`>1.N@N83KH`='``$
- XM8`0@+P`$+P`@+`'(9P0@0$Z03KH0<"QX``0B;`KX3J[^8DZZ"VY*K`'89QHBS
- XM+`'@9P1.KO_<+'@`!$ZN_WPB;`'83J[^AB`?+FP!W$YU<&1@M$/Z`!!P`$ZNO
- XM_=@I0`KX9^Q.=61O<RYL:6)R87)Y`&$```AA``.T8/I.5?_\2.<!(F$``:I!7
- XM[``N+&P``$ZN_S0I0``,2H!F"$*G80`"]%A/(&P`#"EH`#(`$")H`%9P`!`II
- XM``]R`>&A*4$!\&$``;23R2QX``1.KO[:*4``&"!L``PI:``N``@@;``(,"@`9
- XM#$C`<@R0@2E``>@P*``.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6U2!V#:?@$0+?_ZO@!D%'``$`=R`$'L6
- XM`7\2,`@`VH%2!V#D<``0!E2`<@1.N@)22H%F#!`M__IR`K`!8P)2A7``$"W_N
- XM^U.`VH`@!7(83KH"$"H`<``0+?_\VH`@!7(\3KH!_BH`<``0+?_]VH`@!7(\W
- XM3KH!["H`<``0+?_^VH!.NOZ"VJP*Y"`+9P(FA2`%3-\(X$Y=3G4@;P`$(DARS
- XM`'``+P(,$``K9P8,$``M9@)22!`8!```,&T2#```"6X,)`'E@=*"TH'2@F4
- XM#!$`+68"1($D'R`(4X`@;P`(((&0B4YU("P!C"(\```.74ZZ`7!6@`*`?___Y
- XM_RE``8Q.=2\'+B\`""E'`8PN'TYU``!.5?_@2.<O$"9O`$!![?_T(@@L;`KX*
- XM3J[_0"`M__0N/```![HL`"M`__`,A@```6UO'B`'<@1.N@$X2H%F"`2&```!;
- XM;F`&!(8```%M4H=@V@R&```!;680(`=R!$ZZ`1)*@6<$4H=\`"`&(@<$@0``L
- XM![P700`!=``4`2M`__`@`G($3KH`[$J!9@1P'6`"<!P90`&1>``J+?_P<`RX8
- XM@&P><`!![`&0$#!(`+"%;A!P`$'L`9`0,$@`FH!2A<(`4B!%*!%T$``BM`X
- XM__!2@!=```,@+?_T<@=.N@"6%H$@+?_X<CQ.N@"*%T``!"`M__AR/$ZZ`'P7U
- XM00`%("W__'(R3KH`;A=```8@+?_\<C).N@!@TH$700`'3-\(]$Y=3G4`````@
- XM``!P82\'+B\`"$JL`<QG!$ZZ`/XB!RQL"OA.KO_<<``N'TYU````````<&%(3
- XMYS``)``F`4A"2$/$P<;`P,'40TA"0D+0@DS?``Q.=4J`:@``'D2`2H%J```,+
- XM1(%A```@1(%.=6$``!A$@$2!3G5*@6H```Q$@6$```9$@$YU+P)(030!9@``<
- XM(DA`2$%(0C0`9P``!H3!,`)(0#0`A,$P`DA",@(D'TYU+P-V$`Q!`(!D```&[
- XMX9E10PQ!"`!D```&Z9E90PQ!(`!D```&Y9E50TI!:P``!N.94T,T`.:H2$)"T
- XM0N:J2$.`P38`,`(T`TA!Q,&0@F0```A30]"!9/YR`#(#2$/GN$A`P4$F'R0?U
- XM3G5(YP$"<``B/```,``L>``$3J[^SBX``H<``#``2H=F!'``8"!*K`',9Q@@7
- XM;`',3I!*@&8$<`!@#$AX`!1.N@`26$\@!TS?0(!.=6&T3G4``$CG!P`N+P`0,
- XM("P!?%.`+`!*1FLP(`9(P.>`0>P)G"HP"`!*!6<:"`4``F84(`9(P.>`0>P)@
- XMG"\P"`1.NOYH6$]31F#,+P=.NN^66$],WP#@3G4``````````````````$CG(
- XM`#(F;`K\(`MG%"13(DL@*P`(+'@`!$ZN_RXF2F#HD<@I2`L`*4@*_$S?3`!.!
- XM=4CG/@(L;``$(&\`'$SO``,`(")O`"A,[P!\`"Q.KOW83-]`?$YU````````@
- XM``!P80```^P````"`````0```E@```)&`````@````,````,````!@``````\
- XM``/R0``#Z@````8```\`/\`_P`\````?@'_@__#_\'_@'X````/R```#Z0``_
- XM``````/R```#Z@```&<`````````````````````````````````````````)
- XM`"`\/"!#4D%"4R`^/B```!X`R`%>`"@``0```@```!!.```````````````@-
- XM```````````````````````!`````$-A;B=T('!L86-E(&-R86)S(2!.;R!E!
- XM;7!T>2!S<&%C92!F;W5N9"$``&EN='5I=&EO;BYL:6)R87)Y`$-A;B=T(&]P%
- XM96X@26YT=6ET:6]N($QI8G)A<GD``&=R87!H:6-S+FQI8G)A<GD``$-A;B=T,
- XM($]P96X@1W)A<&AI8W,@3&EB<F%R>0!297!R;V1U8VEN9R!#<F%B<R!B>2!!A
- XM;G1H;VYY(%1H>7-S96X``"`@($]R:6=I;F%L(&ED96$@9G)O;2!38VEE;G1IY
- XM9FEC($%M97)I8V%N`$-A;B=T(&%L;&]C(')A<W1E<@``0W)A8G,@87)E($5X;
- XM:71I;F<`5&AE(&QA<W0@0W)A8B!J=7-T(&1I960A"@```````"@?'!\>'QX?K
- XM'QX?'A\````!'QP?'A\>'Q\>'QX?```#[`````$````#````2`````````/RW
- X``
- Xend
- Xsize 5220
- END_OF_FILE
- if test 7341 -ne `wc -c <'crabs.uu'`; then
- echo shar: \"'crabs.uu'\" unpacked with wrong size!
- fi
- # end of 'crabs.uu'
- fi
- if test -f 'intergerize.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'intergerize.c'\"
- else
- echo shar: Extracting \"'intergerize.c'\" \(963 characters\)
- sed "s/^X//" >'intergerize.c' <<'END_OF_FILE'
- X/*
- X** This program filters a small file such that the output
- X** is the set of short ints required to describe the input
- X** NOTE the file must be a rectangle to work and no tabs
- X*/
- X
- X#include <stdio.h>
- X
- Xchar file[100][100];
- Xint linelen, numlines;
- X
- Xmain()
- X{
- X int i;
- X
- X linelen = 0;
- X numlines = 0;
- X while (gets(&file[numlines][0]) != NULL && numlines < 99) {
- X if ((i = strlen(&file[numlines][0])) > linelen)
- X linelen = i;
- X numlines++;
- X }
- X for(i=0; i<numlines; i++) {
- X printf("%s0x%c%c%c%c",
- X !i ? "{ " : i%8 != 7 ? ", " : ",\n ",
- X conv(i,0), conv(i,4), conv(i,8), conv(i,12) );
- X }
- X printf(" };\n");
- X return 0;
- X}
- X
- Xconv(line, pos)
- X{
- X int i;
- X static char hex[] = "0123456789abcdef";
- X
- X i = (file[line][pos] == '*') ? 8 : 0;
- X i += (file[line][pos + 1] == '*') ? 4 : 0;
- X i += (file[line][pos + 2] == '*') ? 2 : 0;
- X i += (file[line][pos + 3] == '*') ? 1 : 0;
- X return (hex[i]);
- X}
- END_OF_FILE
- if test 963 -ne `wc -c <'intergerize.c'`; then
- echo shar: \"'intergerize.c'\" unpacked with wrong size!
- fi
- # end of 'intergerize.c'
- fi
- if test -f 'makefile' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'makefile'\"
- else
- echo shar: Extracting \"'makefile'\" \(504 characters\)
- sed "s/^X//" >'makefile' <<'END_OF_FILE'
- X
- Xcrabs : crabs.c crabs.h crabup.i crabmask.i
- X lc -v -Lc $@
- X
- Xcrabup.i : blob intergerize rotate
- X intergerize <$* >$@
- X copy crabup.i crabdown.i
- X copy crabup.i crableft.i
- X copy crabup.i crabright.i
- X
- Xcrabmask.i : blobmask intergerize
- X intergerize <$* >$@
- X
- Xintergerize : intergerize.c
- X lc -L $@
- X
- Xrotate : rotate.c
- X lc -L $@
- X
- Xmerge : merge.c
- X lc -L $@
- X
- Xclean :
- X delete *.o *.lnk *.i
- X
- Xclobber : clean
- X delete intergerize rotate merge
- END_OF_FILE
- if test 504 -ne `wc -c <'makefile'`; then
- echo shar: \"'makefile'\" unpacked with wrong size!
- fi
- # end of 'makefile'
- fi
- if test -f 'merge.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'merge.c'\"
- else
- echo shar: Extracting \"'merge.c'\" \(556 characters\)
- sed "s/^X//" >'merge.c' <<'END_OF_FILE'
- X/*
- X** This program will read two bitmap file for exactly the
- X** same format and create a or'd version on standard output
- X**
- X** This use is to merge rotated crabs to find the minimal mask
- X*/
- X
- X#include <stdio.h>
- X
- Xmain(argc, argv)
- X int argc;
- X char *argv[];
- X{
- X char c1, c2;
- X FILE *file;
- X
- X if( (file = fopen(argv[1], "r")) == NULL ) {
- X fprintf(stderr,"Can't open the argument file\n");
- X exit(1);
- X }
- X
- X while( (c1=getchar()) != EOF && (c2=getc(file)) != EOF ) {
- X if( c2=='*' )
- X c1='*';
- X putchar(c1);
- X }
- X fclose(file);
- X return 0;
- X}
- END_OF_FILE
- if test 556 -ne `wc -c <'merge.c'`; then
- echo shar: \"'merge.c'\" unpacked with wrong size!
- fi
- # end of 'merge.c'
- fi
- if test -f 'rotate.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'rotate.c'\"
- else
- echo shar: Extracting \"'rotate.c'\" \(614 characters\)
- sed "s/^X//" >'rotate.c' <<'END_OF_FILE'
- X/*
- X** This program filters a small file such that the output
- X** is rotated 90 degrees
- X** NOTE the file must be a rectangle to work and no tabs
- X*/
- X
- X#include <stdio.h>
- X
- Xchar file[100][100];
- Xint linelen, numlines;
- X
- Xmain()
- X{
- X int i,j;
- X char c;
- X
- X linelen = 0;
- X numlines = 0;
- X while (gets(&file[numlines][0]) != NULL && numlines < 99) {
- X if ((i = strlen(&file[numlines][0])) > linelen)
- X linelen = i;
- X numlines++;
- X }
- X for (i = linelen-1; i >= 0; i--) {
- X for( j=0; j <numlines; j++ ){
- X putchar((c=file[j][i])?c:' ');
- X }
- X putchar('\n');
- X }
- X return 0;
- X}
- END_OF_FILE
- if test 614 -ne `wc -c <'rotate.c'`; then
- echo shar: \"'rotate.c'\" unpacked with wrong size!
- fi
- # end of 'rotate.c'
- fi
- echo shar: End of archive 1 \(of 1\).
- cp /dev/null ark1isdone
- MISSING=""
- for I in 1 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have the archive.
- rm -f ark[1-9]isdone
- else
- echo You still need to unpack the following archives:
- echo " " ${MISSING}
- fi
- ## End of shell archive.
- exit 0
- --
- Mail submissions (sources or binaries) to <amiga@uunet.uu.net>.
- Mail comments to the moderator at <amiga-request@uunet.uu.net>.
- Post requests for sources, and general discussion to comp.sys.amiga.
-